<?php

function genArgList($opts, $optvals) {
  $args = "";
  $cnt = 0;
  foreach ($opts as $key => $opt)
    if (array_key_exists($key, $optvals) &&
        $optvals[$key] != NULL )
    {
      if ($cnt != 0) {
        $args.="&amp;";
      }
      $optval = urlencode($optvals[$key]);
      $args.="$opt=$optval";
      $cnt+=1;
    }
  return $args;
}

// get options from http get
$string_opts = array('graph' => 'g', 'grid' => 'G', 'size' => 'z',
                     'start' => 'cs', 'end' => 'ce', 'type' => 't',
                     'jobid' => 'j', 'metric' => 'm', 'host' => 'h'
                     'imgformat' => 'f');
$number_opts = array('max' => 'x', 'min' => 'n', 'debug' => 'debug');
$optvals = array();
foreach ($string_opts as $key => $value) {
  $optvals[$key] = get_string_from_get($value);
}
foreach ($number_opts as $key => $value) {
  $optvals[$key] = get_number_from_get($value);
}

?>
